﻿
@using MvcForum.Core
@using MvcForum.Core.Constants
@using MvcForum.Web.Application.ExtensionMethods
@model MvcForum.Web.ViewModels.Admin.ResourceKeyListViewModel
@{
    ViewBag.Title = "All Resource Keys";
}

@Html.Partial("_LanguageOptions")

<div class="panel">
    <div class="panel-heading">
        <h5>@ViewBag.Title</h5>
    </div>
    <div class="panel-content">
        @using (Html.BeginForm("ManageResourceKeys", "AdminLanguage", FormMethod.Post))
        {
            @Html.ValidationSummary(false)
            @Html.AntiForgeryToken()
            @Html.HiddenFor(x => x.PageIndex)
            <div class="input-group tablesearch">
                @Html.TextBoxFor(x => Model.Search, new { @class = "form-control" })
                <span class="input-group-btn">
                    <button class="btn btn-default" type="submit">Search</button>
                </span>
            </div>
        }

        <table class="table table-bordered table-striped">
            <thead>
                <tr>
                    <th style="width: 65px;">
                        Edit
                    </th>
                    <th>
                        Resource Key
                    </th>
                    <th style="width: 65px;">
                        Delete
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var resource in Model.ResourceKeys)
                {

                    <tr>
                        <td class="languageresourcecell">
                            <span class="editresourcekey">
                                <a href="#" class="btn-mvc">
                                    <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                </a>
                            </span>
                            <span class="saveresourcekey" style="display: none;">
                                <a href="#" class="btn-mvc">
                                    <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
                                </a>
                            </span>
                        </td>
                        <td class="resourcekeyvalue">
                            <strong>
                                <span class="resourcekeyvaluedisplay">
                                    @Html.DisplayFor(modelItem => resource.Name)
                                </span>
                                <span class="resourcekeyvalueedit form-group" style="display: none;">
                                    <input data-resourcekeyid="@resource.Id" data-oldvalue="@resource.Name" type="text" id="@resource.Id" value="@resource.Name" class="resourcekeyinput form-control" />
                                </span>
                            </strong>
                        </td>
                        <td>
                            <a href="@Url.Action("DeleteResourceConfirmation", new { resourceKeyId = resource.Id })" class="btn-mvc">
                                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                            </a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>

        @if (Model.TotalPages > 1)
        {
            @Html.Pager(Convert.ToInt32(Model.PageIndex), ForumConfiguration.Instance.AdminListPageSize, Convert.ToInt32(Model.TotalCount), new { search = Model.Search })
        }

    </div>
</div>




